package com.lee.dutylower.db.greenEntity;


import com.lee.dutylower.db.BaseDB;

import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;
import com.lee.dutylower.db.greendao.DaoSession;
import com.lee.dutylower.db.greendao.SquadDao;
import com.lee.dutylower.db.greendao.SquadRecordDao;

/**
 * Created by lijie on 2017/5/15.
 */
@Entity
public class SquadRecord  extends BaseDB {
    @Id(autoincrement = true)
    private Long sRecordID;
    @Property
    private Long squadID;
    @ToOne(joinProperty = "squadID")
    private Squad squad;
    @Property
    private Integer squadType;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 1005120501)
    private transient SquadRecordDao myDao;
    @Generated(hash = 887771605)
    public SquadRecord(Long sRecordID, Long squadID, Integer squadType) {
        this.sRecordID = sRecordID;
        this.squadID = squadID;
        this.squadType = squadType;
    }
    @Generated(hash = 556388288)
    public SquadRecord() {
    }
    public Long getSRecordID() {
        return this.sRecordID;
    }
    public void setSRecordID(Long sRecordID) {
        this.sRecordID = sRecordID;
    }
    public Long getSquadID() {
        return this.squadID;
    }
    public void setSquadID(Long squadID) {
        this.squadID = squadID;
    }
    public Integer getSquadType() {
        return this.squadType;
    }
    public void setSquadType(Integer squadType) {
        this.squadType = squadType;
    }
    @Generated(hash = 2016322389)
    private transient Long squad__resolvedKey;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1519719723)
    public Squad getSquad() {
        Long __key = this.squadID;
        if (squad__resolvedKey == null || !squad__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            SquadDao targetDao = daoSession.getSquadDao();
            Squad squadNew = targetDao.load(__key);
            synchronized (this) {
                squad = squadNew;
                squad__resolvedKey = __key;
            }
        }
        return squad;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 246468666)
    public void setSquad(Squad squad) {
        synchronized (this) {
            this.squad = squad;
            squadID = squad == null ? null : squad.getSuqadId();
            squad__resolvedKey = squadID;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1479298489)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getSquadRecordDao() : null;
    }

}
